﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace StarfleetCommanderDomain.Game
{
    public enum Engine
    {
        Jet,
        Pulse,
        Warp
    }
    public class Flight
    {
        public Engine Engine { get; private set; }
        public int BaseSpeed { get; private set; }
        public int FuelConsumption { get; private set; }
        public Flight(int baseSpeed, Engine engine, int fuelConsumption)
        {
            BaseSpeed = baseSpeed;
            Engine = engine;
            FuelConsumption = fuelConsumption;
        }
        public decimal Modifier
        {
            get
            {
                switch (Engine)
                {
                    case Engine.Jet:
                        return .1M;
                    case Engine.Pulse:
                        return .2M;
                    case Engine.Warp:
                        return .3M;
                    default:
                        throw new NotSupportedException();
                }
            }
        }
        public int CalculateMaxSpeed(int techLevel)
        {
            return (int)( BaseSpeed + techLevel * Modifier);
        }
        public int CalculateConsumption(int techLevel, int distance)
        {
            return FuelConsumption * (distance / 35000) * (1 /* speed selector */
                * (1^(1/2)) + 1) ^ 2;
        }
        public int CalculateConsumption(int techLevel, int distance, int effectiveSpeedCap)
        {
            return FuelConsumption * (distance / 35000) * (1 * (effectiveSpeedCap / CalculateMaxSpeed(techLevel)) ^ (1 / 2) + 1) ^ 2;
        }
        //public int CalculateConsumption(int techLevel, int distance, decimal speedSelector)
        //{

        //}
    }

    public class Combatant
    {
       
 
        public bool Movable { get { return Flight1!=null; } }
        public Flight Flight1{get; private set;}
        public Flight Flight2{get; private set;}

        public bool MakesDebris { get; private set; }
        public int OreCost { get; private set; }
        public int CrystalCost { get; private set; }
        public int HydrogenCost { get; private set; }
        public string Name { get; private set; }
        public int Fuel { get; private set; }
        public string ShortName { get { return Name.Replace(" ", ""); } }

        /// <summary>
        /// Ground Defenses
        /// </summary>
        /// <param name="name"></param>
        /// <param name="oreCost"></param>
        /// <param name="crystalCost"></param>
        /// <param name="hydrogenCost"></param>
              public Combatant(string name, int oreCost, int crystalCost, int hydrogenCost)
        {
            Name = name;
            OreCost = oreCost;
            CrystalCost =crystalCost ;
            HydrogenCost = hydrogenCost;

        }
        //Helios only?
        public Combatant(string name,bool makesDebris, int oreCost,
            int crystalCost, int hydrogenCost):this(name,oreCost,crystalCost,hydrogenCost)
        {
            MakesDebris = makesDebris;
        }


        public Combatant(string name, bool makesDebris, int oreCost,
      int crystalCost, int hydrogenCost, Flight flight)
            : this(name, makesDebris, oreCost, crystalCost, hydrogenCost)
        {
            Flight1 = flight;
        }
        public Combatant(string name, bool makesDebris, int oreCost,
            int crystalCost, int hydrogenCost, Flight flight1, Flight flight2):this(name,makesDebris,oreCost,crystalCost,hydrogenCost,flight1)
        {
            Flight2 = flight2;
        }

        
    }


}
